<template>
  <view class="content">
    <view class="content-box">
        <view class="content-font">
            <view >Hi，你 好</view>
            <view > 欢 迎 您 使 用 记 账 系 统</view>
        </view>
    </view>
      <view class="content-login">

          <view style="width: 80%; margin: 0 auto">
              <u-button type="primary" @click="handleLogin" text="微信一键登录"></u-button>
          </view>
          <view class="dis_f_r_c m_t_10">
              <u-checkbox-group
                  size="16"
                  v-model="checkboxValue"
                  placement="column">
                  <u-checkbox
                      activeColor="#2b85e4"
                      label=" "
                      name="agreement"
                  >
                  </u-checkbox>
              </u-checkbox-group>
              <view class="f_s_14 c_primaryColor"> <text  @click="handleToProtocol(2)"> 《用户协议》</text>和 <text  @click="handleToProtocol(3)"> 《隐私协议》 </text></view>
          </view>

      </view>

  </view>
</template>

<script>
import {loginApi} from "@/sheep/api/login";
export default {
  data() {
    return {
        checkboxValue: [],
    };
  },
  onShow(options) {},
  methods: {
      handleLogin(){
          if (this.checkboxValue.length==0){
              uni.showToast({
                  title: '请勾选用户协议和隐私协议',
                  icon: 'none'
              })
              return
          }
          let loginBody = {
              xcxCode: "",
              isBindPhone: false,
              clientId: "be7052a7e4f802c20df10a8d131adb12",
              grantType: "xcx",
              tenantId: "000000",
          };
          uni.login({
              provider: "weixin",
              success: function (loginRes) {
                  loginBody.xcxCode = loginRes.code;
                  loginApi(loginBody).then((res) => {
                      if (res.code === 200) {
                          uni.setStorageSync('token',res.data.access_token)
                          uni.navigateTo ({
                              url: "/pages/index/index",
                          })
                      }
                  });
              },
              fail(res) {
                  console.log(res, "登录失败");
              },
          });

      },

      handleToProtocol(e){
          uni.navigateTo({
              url: '/pages/agreement/index?type='+e
          })
      },

  },
};
</script>

<style lang="scss" scoped>
.content{
    position: relative;
    width: 100vw;
    height: 100vh;
    background-color: #f6f4f6;

}
.content-box{
    width: 100%;
    height: 23%;
    background-color: #2b85e4;
    border-bottom-right-radius: 40rpx;
}
.content-font{
    padding: 50rpx 30rpx 0 ;
    color: #c8c7cc;
    font-size: 50rpx;
}

.content-login{
    position: absolute;
    top: 264rpx;
    left: 50%;
    transform: translateX(-50%);
    width:90%;
    padding: 20rpx;
    border-radius: 10rpx;

    background-color: #fff;
}
</style>
